summaryrefslogtreecommitdiff
path: root/bloodfields.stage
blob: 81ff6e198713e0828344ef817823c15bdf0e6f2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
game.title = "Bloodfields";

global
{
	command: "quit"
	{
		exit();
	}
}

situation <<start>>
{
	setup
	{
		player.hpMax = 10;
		player.hpCur = player.hpMax;
		player.xp = 0;
		player.attack = 3;

		global.bJustTravelled = false;

		goto( <<field>> );
	}
}

function status()
{
	display('You have ' + player.hpCur + ' of ' + player.hpMax + ' hp.');
}

function look()
{
	if( exists(global.enemy) )then
	{
		display('''You are standing in a field of wheat.  You see a ''' +
			global.enemy['name'] + ''' in front of you.''');
	}
	else
	{
		display('''You are standing in a field of wheat.''');
	}
//	status();
}

function mkEnemy()
{
	global.enemy = {
		'name': 'Snail',
		'weapon': 'Tooth',
		'attack': 3,
		'hp': 5
	};
}

function rollAttack( attack )
{
	return( random( attack-attack/3, attack+attack/3 ) );
}

function playerAttack()
{
	damage = rollAttack( player.attack );
	global.enemy['hp'] = global.enemy['hp'] - damage;
	display('You strike the ' + global.enemy['name'] + ' for ' + damage +
		' damage.');
	if global.enemy['hp'] <= 0 then
	{
		display('You killed the ' + global.enemy['name'] + '!');
		delete( global.enemy );
	}
}

function enemyAttack()
{
	damage = rollAttack( global.enemy['attack'] );
	player.hpCur -= damage;
	display("The " + global.enemy['name'] + ' strikes you for ' + damage +
		' damage.');
	if player.hpCur <= 0 then
	{
		display('The ' + global.enemy['name'] + ' killed you!');
		exit();
	}
}

situation <<travel>>
{
	enter
	{
		delete( global.enemy );
		
		display('You wander aimlessly through the seemingly endless field of wheat.');

		select = random(1,3);
		if select == 1 then
		{
			mkEnemy();
			display('''There's a ''' + global.enemy['name'] + ''' here!''');
		}

		global.bJustTravelled = true;

		goto( <<field>> );
	}
}

situation <<field>>
{
	command: "attack"
	{
		if exists(global.enemy) then
		{
			playerAttack();
			goto( <<field>> );
		}
		else
		{
			display('''There's nothing here to attack...''');
		}
	}

	command: "look"
	{
		look();
	}

	command: "walk"
	{
		if not exists(global.enemy) then
		{
			goto( <<travel>> );
		}
		else
		{
			display("You can't walk around with an enemy in front of you! 
				You can try to flee if you'd like...");
		}
	}

	setup
	{
		look();
	}

	enter
	{
		if not global.bJustTravelled then
		{
			if exists( global.enemy ) then
			{
				enemyAttack();
			}
			status();
//			look();
		}
		else
		{
		}
		global.bJustTravelled = false;
	}
}